﻿Imports System.Text

Namespace DotNetNuke.Modules.ActiveForums.Controls
    Public Class ToggleSubscribe
        Public Property ToggleMode() As Integer = 0 '0= Forum, 1=Topic
        Public Property DisplayMode() As Integer = 0 '0=checkbox, 1=link
        Public Property ForumId() As Integer = -1
        Public Property TopicId() As Integer = -1
        Public Property Checked() As Boolean = False
        Public Property Text() As String = String.Empty
        Public Property UserId() As Integer = -1
        Public Property ImageURL() As String = String.Empty

        Sub New(ByVal m As Integer, ByVal f As Integer, ByVal t As Integer)
            ToggleMode = m
            ForumId = f
            TopicId = t
        End Sub
        'amaf_topicSubscribe
        Public Function Render() As String
            Dim sb As New StringBuilder
            If DisplayMode = 0 Then
                sb.Append("<span class=""afnormal"">")
                sb.Append("<input id=""amaf-chk-subs"" type=""checkbox"" ")
                If Checked Then
                    sb.Append("checked=""checked"" ")
                End If
                If ToggleMode = 0 Then
                    sb.Append(" onclick=""amaf_forumSubscribe(" & ForumId & ");"" />")
                Else
                    sb.Append(" onclick=""amaf_topicSubscribe(" & ForumId & "," & TopicId & ");"" />")
                End If

                sb.Append("<label for=""amaf-chk-subs"">" & Text & "</label>")
                sb.Append("</span>")
            Else
                sb.Append("<img src=""" & ImageURL & """ border=""0"" alt=""" & Text & """ onclick=""amaf_forumSubscribe(" & ForumId & ", " & UserId & ");"" id=""amaf-sub-" & ForumId & """ />")
            End If

            Return sb.ToString
        End Function

    End Class
End Namespace

